<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class ConfigController extends Controller {

    public function sitting() {
        $data= \DB::table('config')->first();
        return view('config.sitting')->with("data",$data);
    }

    public function add(request $request) {
        $arr = $request->all();
        unset($arr['_token']);
        if(\DB::table('config')->where("id",1)->first()){ 
           if(\DB::table("config")->where("id",1)->update($arr)){
             return redirect('/admin/config/sitting');  
           }else{
             return back()->withInput();
           }
        }else{
             if (\DB::table("config")->insert($arr)) {
            return redirect('/admin/config/sitting');
        }else{
             return back()->withInput();
        }
        } 
    }

}
